using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class EnemyStateBar : MonoBehaviour
{
    public Image healthImage;

    public CharacterEventSO enemyHealthChange;

    private void OnEnable()
    {
        enemyHealthChange.OnEventRaised += OnEnemyHealthChange;
    }

    private void OnDisable()
    {
        enemyHealthChange.OnEventRaised -= OnEnemyHealthChange;
    }

    private void OnEnemyHealthChange(Character arg0)
    {
        var percent = arg0.currentHealth/arg0.maxHealth;
        OnHealthChange(percent);
    }

    public void OnHealthChange(float presentage)
    {
        healthImage.fillAmount = presentage;
    }
}
